package com.shenmazong.servereduuser.controller;

import com.shenmazong.servereduuser.entity.TbUserRole;
import com.shenmazong.servereduuser.service.TbUserRoleService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.BatchChooseIdVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @author GuanJiaHe
 * @version 1.0
 * @description TODO
 * @date 2021/9/22 20:46
 */
@Api(tags = {"用户与角色API接口"})
@RestController
@RequestMapping(value = "/UserAndRole")
public class TbUserRoleController {

    @Autowired
    private TbUserRoleService userRoleService;

    @PostMapping("createRoleToUser")
    public ResultResponse createRoleToUser(@RequestParam Long userId, @RequestBody ArrayList<Long> roleIds){
        return userRoleService.createRoleToUser(userId,roleIds);
    }

    @DeleteMapping("deleteRoleByUserRoleIds")
    public ResultResponse deleteRoleByUserRoleIds(@RequestBody BatchChooseIdVo chooseIdVo){
        return userRoleService.deleteRoleByUserRoleIds(chooseIdVo);
    }

    @PostMapping("getAllRoleByUserId")
    public ResultResponse getAllRoleByUserId(@RequestParam Long userId){
        return userRoleService.getAllRoleByUserId(userId);
    }

    @PostMapping("updateRoleByUserRoleId")
    public ResultResponse updateRoleByUserId(@RequestBody TbUserRole userRole){

        return userRoleService.updateRoleByUserId(userRole);
    }
}
